package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.RoomType;
import com.ruoyi.system.mapper.RoomMapper;
import com.ruoyi.system.mapper.RoomTypeMapper;
import com.ruoyi.system.service.IRoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomTypeServiceImpl implements IRoomTypeService {
    @Autowired
    private RoomTypeMapper roomTypeMapper;

    @Autowired
    private RoomMapper roomMapper;


    @Override
    public List<RoomType> getRoomTypeAndRooms(Long hotelId) {
        // 查询酒店对应的所有roomType
        List<RoomType> typeList = roomTypeMapper.getRoomTypeByHotelId(hotelId);
        return typeList;
    }

    @Override
    public void addRoomType(RoomType roomType) {
        roomType.setCreateTime(DateUtils.getNowDate());
        roomType.setIsDelete(0);
        roomTypeMapper.addRoomType(roomType);
    }

    @Override
    public void updateRoomType(RoomType roomType) {
        roomType.setUpdateTime(DateUtils.getNowDate());
        roomTypeMapper.updateRoomType(roomType);
    }

    @Override
    public RoomType getRoomTypeById(Long id) {
        RoomType roomType = roomTypeMapper.getRoomTypeById(id);
        return roomType;
    }

    @Override
    public void deleteRoomType(Long id) {
        roomTypeMapper.deleteRoomType(id);
    }


}
